﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bosphorus.Migrator.Dialect.Core;
using NVelocity.App;
using Commons.Collections;
using NVelocity;
using System.IO;

namespace Bosphorus.Migrator.Dialect.NVelocity
{
    public class TableNVelocityDialect : AbstractDialect<NVelocityModel>
    {
        private VelocityEngine engine;

        public TableNVelocityDialect()
        {
            engine = new VelocityEngine();
            ExtendedProperties properties = new ExtendedProperties();
            engine.Init(properties);
        }

        public override string Create(NVelocityModel nvelocityModel)
        {
            VelocityContext context = new VelocityContext();
            context.Put("Model", nvelocityModel);
            StringWriter writer = new StringWriter();
            Template template = engine.GetTemplate(@"Table.Create.vm");
            template.Merge(context, writer);
            return writer.GetStringBuilder().ToString();
        }

        public override string Alter(NVelocityModel nvelocityModel)
        {
            throw new NotImplementedException();
        }

        public override string Drop(NVelocityModel nvelocityModel)
        {
            throw new NotImplementedException();
        }
    }
}
